package com.yanqu.road.server.manger.activity.dafuweng.event;

import com.yanqu.road.entity.activity.dafuweng.DFWConfig;
import com.yanqu.road.entity.activity.dafuweng.DFWEvent;
import com.yanqu.road.entity.config.goods.MallInfo;
import com.yanqu.road.entity.enums.eShopType;
import com.yanqu.road.entity.log.LogDFWPackage;
import com.yanqu.road.server.manger.activity.NormalActivityMgr;
import com.yanqu.road.server.manger.activity.dafuweng.DaFuWengMgr;
import com.yanqu.road.server.manger.activity.dafuweng.building.BaseDFWBuilding;
import com.yanqu.road.server.manger.log.AutoLogMgr;
import com.yanqu.road.server.manger.log.LogMgr;

/**
 * @Author wpj
 * @Date 2021/1/7
 */
public class DFWPackageEvent extends BaseDFWEvent {

    public DFWPackageEvent(BaseDFWBuilding baseDFWBuilding, DFWEvent dfwEvent) {
        super(baseDFWBuilding, dfwEvent);
    }

    @Override
    public void doEvent() {
        userData.setEventId(dfwEvent.getEventId());
        userData.setExpandParam("1,1"); //元宝礼包购买次数,现金礼包购买次数
        userData.setComplete(false);
        DFWConfig config = baseDFWBuilding.getDfwConfig();
        try {
            //礼包日志
            MallInfo mallInfo1 = NormalActivityMgr.getRMBActivityMallInfoByShopTypeAndExtendParam(config.getActivityInfo().getActivityId(), eShopType.DaFuWengGoldMall.getValue(), dfwEvent.getParamList().get(0));
            MallInfo mallInfo2 = NormalActivityMgr.getRMBActivityMallInfoByShopTypeAndExtendParam(config.getActivityInfo().getActivityId(), eShopType.DaFuWengMoneyMall.getValue(), dfwEvent.getParamList().get(1));
            AutoLogMgr.add(new LogDFWPackage(config.getActivityInfo().getActivityId(), userData.getUserId(), mallInfo1.getMallName()));
            AutoLogMgr.add(new LogDFWPackage(config.getActivityInfo().getActivityId(), userData.getUserId(), mallInfo2.getMallName()));
            if (userData.isTenRoll()) {
                userData.addPackage(dfwEvent.getParamList().get(0), eShopType.DaFuWengGoldMall.getValue());
            }
            userData.addPackage(dfwEvent.getParamList().get(1), eShopType.DaFuWengMoneyMall.getValue());
        } catch (Exception e) {
            DaFuWengMgr.getLogger().error(e.getMessage(), e);
        }
    }
}
